package net.simflow.swf.analyzer.bgnetwork.data;

import java.util.Collection;
import java.util.HashSet;

import net.simflow.swf.analyzer.network.data.Flow;
import net.simflow.swf.analyzer.network.data.Service;

public class BGNode {

	private String nameInBG;

	private Service service;
	private Flow flow;
	private HashSet<BGNode> neighborSet = new HashSet<BGNode>();

	public BGNode(Service service) {
		this.nameInBG = service.getNameInNetwork();
		this.service = service;
	}

	public BGNode(Flow flow) {
		this.nameInBG = flow.getNameInNetwork();
		this.flow = flow;
	}

	public void addNeighbor(BGNode neighbor) {
		this.neighborSet.add(neighbor);
	}

	public void addNeighborSet(Collection<? extends BGNode> set) {
		this.neighborSet.addAll(set);
	}

	public void removeNeighbor(BGNode neighbor) {
		this.neighborSet.remove(neighbor);
	}

	public void clearNeighborSet() {
		this.neighborSet.clear();
	}

	public String getNameInBG() {
		return nameInBG;
	}

	public Service getService() {
		return service;
	}

	public Flow getFlow() {
		return flow;
	}

	public HashSet<BGNode> getNeighborSet() {
		return neighborSet;
	}

	public String getShortInfo() {
		return this.getNameInBG();
	}

	public String getFullInfo() {
		if (this.flow != null) {
			return this.flow.getFullInfo();
		}

		if (this.service != null) {
			return this.service.getFullInfo();
		}

		return "";
	}
}
